{% extends "teacher/teacher_base.html" %}
{% block title %}个人信息{% endblock %}
{% block content %}
<div class="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
    <!-- 个人信息卡片 -->
    <div class="bg-white rounded-2xl shadow-lg overflow-hidden mb-8 transition-all duration-300 hover:shadow-xl">
        <div class="flex flex-col md:flex-row">
            <!-- 头像区域 -->
            <div class="bg-gradient-to-br from-blue-50 to-blue-100 p-8 md:p-10 flex flex-col items-center justify-center">
                <div class="w-40 h-40 rounded-full overflow-hidden border-4 border-white shadow-lg">
                    <img src="https://picsum.photos/100/100"
                         alt="教师头像"
                         class="w-full h-full object-cover" type="image/webp">
                </div>
                <p class="mt-4 text-sm text-gray-500 text-center">头像由管理员统一设置</p>
            </div>

<div class="p-8 md:p-10 flex-1">
                <div class="flex flex-col md:flex-row md:items-center justify-between mb-8">

                    <div>
                        <h2 class="text-2xl font-bold text-gray-800 mb-2">
                            {{ teacher.username }}

                        </h2>
                        <p class="text-lg text-gray-600">
                            <span class="mr-6">
                                <i class="fa fa-graduation-cap text-gray-500 mr-1"></i>
                               {{ teacher.teacher_no }}
                            </span>
                            <span>
                                <i class="fa fa-users text-gray-500 mr-1"></i>
                               {{ teacher.department }}
                            </span>
                        </p>
                    </div>




                    <!-- 保存按钮 -->
                    <div class="mt-6 md:mt-0 flex gap-4">
                        <button id="saveBtn" class="btn bg-green-500 hover:bg-green-600 text-white px-4 py-2 rounded-md transition-all">
                            <i class="fa fa-save mr-2"></i> 保存更改
                        </button>
                    </div>
                </div>

                <!-- 表单区域 -->
                <form id="profileForm" method="POST" action="#" novalidate>
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-x-8 gap-y-6">
                        <!-- 电子邮箱 -->
                        <div>
                            <label for="email" class="block text-sm text-gray-500 mb-1">电子邮箱</label>
                            <div class="relative">
                                <span class="absolute inset-y-0 left-0 pl-3 flex items-center text-gray-500">
                                    <i class="fa fa-envelope"></i>
                                </span>
                                <input type="email" id="email" name="email"
                                       value="{{ teacher.email or '' }}"
                                       class="w-full pl-10 pr-4 py-2 border border-gray-200 rounded-md bg-white focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all">
                            </div>
                        </div>

                        <!-- 联系电话 -->
                        <div>
                            <label for="telephone" class="block text-sm text-gray-500 mb-1">联系电话</label>
                            <div class="relative">
                                <span class="absolute inset-y-0 left-0 pl-3 flex items-center text-gray-500">
                                    <i class="fa fa-phone"></i>
                                </span>
                                <input type="text" id="telephone" name="telephone"
                                       value="{{ teacher.telephone or '' }}"
                                       class="w-full pl-10 pr-4 py-2 border border-gray-200 rounded-md bg-white focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all">
                            </div>
                        </div>

                        <!-- 入职日期（不可编辑） -->
                        <div>
                            <label for="hire_date" class="block text-sm text-gray-500 mb-1">入职日期</label>
                            <div class="relative">
                                <span class="absolute inset-y-0 left-0 pl-3 flex items-center text-gray-500">
                                    <i class="fa fa-calendar"></i>
                                </span>
                                <input type="text" id="hire_date"
                                       value="{{ teacher.hire_date.strftime('%Y-%m-%d') if teacher.hire_date else '未设置' }}"
                                       class="w-full pl-10 pr-4 py-2 border border-gray-200 rounded-md bg-gray-50 focus:outline-none"
                                       disabled>
                            </div>
                        </div>

                        <!-- 职称（不可编辑） -->
                        <div>
                            <label for="title" class="block text-sm text-gray-500 mb-1">职称</label>
                            <div class="relative">
                                <span class="absolute inset-y-0 left-0 pl-3 flex items-center text-gray-500">
                                    <i class="fa fa-award"></i>
                                </span>
                                <input type="text" id="title" name="title"
                                       value="{{ teacher.title or '' }}"
                                       class="w-full pl-10 pr-4 py-2 border border-gray-200 rounded-md bg-gray-50 focus:outline-none"
                                       disabled>
                            </div>
                        </div>

                        <!-- 办公地址 -->
                        <div class="md:col-span-2">
                            <label for="address" class="block text-sm text-gray-500 mb-1">办公地址</label>
                            <div class="relative">
                                <span class="absolute inset-y-0 left-0 pl-3 flex items-center text-gray-500">
                                    <i class="fa fa-map-marker"></i>
                                </span>
                                <input type="text" id="address" name="address"
                                       value="{{ teacher.address or '' }}"
                                       class="w-full pl-10 pr-4 py-2 border border-gray-200 rounded-md bg-white focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all">
                            </div>
                        </div>
                    </div>

                    <!-- 密码修改区域 -->
                    <!-- 当前密码 -->
<div id="passwordSection" class="mt-8">
    <h3 class="text-lg font-medium text-gray-800 mb-4">修改密码</h3>

    <div class="grid grid-cols-1 md:grid-cols-2 gap-x-8 gap-y-6">
        <!-- 当前密码 -->
        <div class="md:col-span-2">
            <label for="current_password" class="block text-sm text-gray-500 mb-1">当前密码</label>
            <div class="relative">
                <span class="absolute inset-y-0 left-0 pl-3 flex items-center text-gray-500">
                    <i class="fa fa-lock"></i>
                </span>
                <input type="password" id="current_password" name="current_password" value="{{ teacher.password }}"
                       class="w-full pl-10 pr-10 py-2 border border-gray-200 rounded-md bg-white focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all"
                       placeholder="请输入当前密码">
                <!-- 修正：只保留一个显示按钮 -->
                <button type="button" class="absolute right-0 pr-3 top-1/2 transform -translate-y-1/2" id="toggleCurrentPassword">
                    <i class="fa fa-eye-slash text-gray-500" id="currentPasswordIcon"></i>
                </button>
            </div>
        </div>

        <!-- 新密码 -->
        <div>
            <label for="new_password" class="block text-sm text-gray-500 mb-1">新密码</label>
            <div class="relative">
                <span class="absolute inset-y-0 left-0 pl-3 flex items-center text-gray-500">
                    <i class="fa fa-key"></i>
                </span>
                <input type="password" id="new_password" name="new_password"
                       class="w-full pl-10 pr-10 py-2 border border-gray-200 rounded-md bg-white focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all"
                       placeholder="请输入新密码">
                <!-- 修正：只保留一个显示按钮 -->
                <button type="button" class="absolute right-0 pr-3 top-1/2 transform -translate-y-1/2" id="toggleNewPassword">
                    <i class="fa fa-eye-slash text-gray-500" id="newPasswordIcon"></i>
                </button>
            </div>
        </div>

        <!-- 确认新密码 -->
        <div>
            <label for="confirm_password" class="block text-sm text-gray-500 mb-1">确认新密码</label>
            <div class="relative">
                <span class="absolute inset-y-0 left-0 pl-3 flex items-center text-gray-500">
                    <i class="fa fa-check-circle"></i>
                </span>
                <input type="password" id="confirm_password" name="confirm_password"
                       class="w-full pl-10 pr-10 py-2 border border-gray-200 rounded-md bg-white focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all"
                       placeholder="请再次输入新密码">
                <!-- 修正：只保留一个显示按钮 -->
                <button type="button" class="absolute right-0 pr-3 top-1/2 transform -translate-y-1/2" id="toggleConfirmPassword">
                    <i class="fa fa-eye-slash text-gray-500" id="confirmPasswordIcon"></i>
                </button>
            </div>
        </div>
    </div>
</div>
                </form>
            </div>
        </div>
    </div>
</div>
    <script src="{{ url_for('static', filename='js/teacher_js/message.js') }}"></script>
{% endblock %}